#include "chipplace.h"
#include "chip.h"

ChipPlace::ChipPlace(int row, int col, int size, const QColor &color) : row(row), col(col), size(size), color(color)
{
}

void ChipPlace::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setPen(color);
    painter->drawEllipse(boundingRect());
}

QRectF ChipPlace::boundingRect() const
{
    return QRectF(0, 0, size, size);
}

int ChipPlace::getRow()
{
    return row;
}

int ChipPlace::getCol()
{
    return col;
}

Chip* ChipPlace::getChipItem()
{
    QList<QGraphicsItem*> chipList = collidingItems();
    if(chipList.size() == 1) return qgraphicsitem_cast<Chip*>(chipList[0]);
    return NULL;
}

